#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <ncurses/ncurses.h>

using namespace std;

int main(void) {

	WINDOW * mainwin;
	
	if ( (mainwin = initscr()) == NULL ) {
		fprintf(stderr, "Error initialising ncurses.\n");
		exit(EXIT_FAILURE);
	}
	
	mvaddstr(1, 5, "Bienvenue dans le chat");
	mvaddstr(2, 3, "Votre nom ? ");
	refresh();
	
	string s;
	
	int c;
	bool b=true;
	do {
		//timeout(5);
		c = getch();
		
		if(c != -1)
		{
			if(c == '\n')
			{
				b = false;
			}
			else
			{
				s+=c;
			}
		}
	} while(c && b);
	
	refresh();
	
	mvaddstr(6, 3, s.c_str());
	
	//sleep(3);
	
	refresh();
	sleep(3);
	
	delwin(mainwin);
	endwin();
	
	
	
	//refresh();
	
	return EXIT_SUCCESS;
}
